#!/bin/python

#
# delete-dssstore.py
#
# A simple python script to delete .DS_Store files
#
# Angelito M. Goulart
# www.angelitomg.com
#
# April/2013
#

import os


def dsStoreFile(file):
    i = 0
    listdir = os.listdir(file)
    for dir in listdir:
        try:
            if os.path.isdir(file + "\\" + dir):
                a = dsStoreFile(file + "\\" + dir)
                i = i + a
            else:
                if dir == '.DS_Store':
                    ds = file + "\\" + dir
                    i = i + 1
                    print(ds)
                    # os.remove(ds)
        except Exception as e:
            print(dir)
            continue;
    return i


if __name__ == '__main__':
    file = 'D:\\Documents'
    v = dsStoreFile(file)
    print('Total:' + str(v))
    print(v)
